Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gemspec: Remove unnecessary files from gem file #4534

Merged

Conversation

daipom
Copy link
Contributor

@daipom daipom commented Jun 20, 2024

Which issue(s) this PR fixes:
None.

What this PR does / why we need it:
Remove the following files from the gem file:

  • test files
  • git files
  • Gemfile

This reduces the gem file size: 867k -> 558k.

We should reflect recent gemspec moves as the current files and test_files are written more than 10 years ago:

test_files is not documented anymore:

Looks like it is not recommended:

Looks like we should also remove git files and Gemfile because the template of Bundler 2.4.13 is as follows:

spec.files = Dir.chdir(__dir__) do
  `git ls-files -z`.split("\x0").reject do |f|
    (File.expand_path(f) == __FILE__) ||
      f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
  end
end

The removed files except for test/* are as follows:

before = `git ls-files`.split($\)
after = Dir.chdir(__dir__) do
  `git ls-files -z`.split("\x0").reject do |f|
    (File.expand_path(f) == __FILE__) ||
      f.start_with?(*%w[test/ .git Gemfile])
  end
end
before.reject{|path| path.start_with? "test/"}.difference after
=>
[".github/DISCUSSION_TEMPLATE/q-a-japanese.yml",
 ".github/DISCUSSION_TEMPLATE/q-a.yml",
 ".github/ISSUE_TEMPLATE.md",
 ".github/ISSUE_TEMPLATE/bug_report.yml",
 ".github/ISSUE_TEMPLATE/config.yml",
 ".github/ISSUE_TEMPLATE/feature_request.yml",
 ".github/PULL_REQUEST_TEMPLATE.md",
 ".github/workflows/stale-actions.yml",
 ".github/workflows/test-ruby-head.yml",
 ".github/workflows/test.yml",
 ".gitignore",
 "Gemfile"]

after.difference before
=> []

Docs Changes:
Not needed.

Release Note:
Not needed.

This reduces Gem file size: 867k -> 558k

Remove:

* test files
* git files
* Gemfile

`test_files` is not documented anymore:

* https://guides.rubygems.org/specification-reference

Looks like it is not recommended:

* rubygems/bundler#3207

Looks like we should also remove git files and Gemfile because
the template of Bundler 2.4.13 is as follows:

    spec.files = Dir.chdir(__dir__) do
      `git ls-files -z`.split("\x0").reject do |f|
        (File.expand_path(f) == __FILE__) ||
          f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
      end
    end

The removed files except for `test/*` are as follows:

    before = `git ls-files`.split($\)
    after = Dir.chdir(__dir__) do
      `git ls-files -z`.split("\x0").reject do |f|
        (File.expand_path(f) == __FILE__) ||
          f.start_with?(*%w[test/ .git Gemfile])
      end
    end
    before.reject{|path| path.start_with? "test/"}.difference after
    =>
    [".github/DISCUSSION_TEMPLATE/q-a-japanese.yml",
     ".github/DISCUSSION_TEMPLATE/q-a.yml",
     ".github/ISSUE_TEMPLATE.md",
     ".github/ISSUE_TEMPLATE/bug_report.yml",
     ".github/ISSUE_TEMPLATE/config.yml",
     ".github/ISSUE_TEMPLATE/feature_request.yml",
     ".github/PULL_REQUEST_TEMPLATE.md",
     ".github/workflows/stale-actions.yml",
     ".github/workflows/test-ruby-head.yml",
     ".github/workflows/test.yml",
     ".gitignore",
     "Gemfile"]

    after.difference before
    => []

Signed-off-by: Daijiro Fukuda <[email protected]>
Copy link
Member

@ashie ashie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thanks!

@ashie ashie merged commit 329c9ae into fluent:master Jul 6, 2024
13 of 16 checks passed
@daipom daipom deleted the gemspec-remove-unnecessary-files-from-gem branch August 15, 2024 02:52
@daipom daipom added this to the v1.17.1 milestone Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants